package k8s

import (
    "context"
    "k8s.io/client-go/informers"
    informerscorev1 "k8s.io/client-go/informers/core/v1"
    "time"
)

var (
    endpointsInformer informerscorev1.EndpointsInformer
)

func EndpointsInformer() informerscorev1.EndpointsInformer {
    return endpointsInformer
}

func initEndpointsInformer(ctx context.Context) {
    sharedInformerFactory := informers.NewSharedInformerFactory(clientset, 20*time.Hour)

    endpointsInformer = sharedInformerFactory.Core().V1().Endpoints()

    endpointsInformer.Lister()
    endpointsInformer.Informer()

    sharedInformerFactory.Start(ctx.Done())
    sharedInformerFactory.WaitForCacheSync(ctx.Done())
}
